home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Hamster.EXE / hstrings.hsm < prev    next >
Encoding:
Text File  |  2000-05-07  |  1.8 KB  |  48 lines

  1. ########################################################################
  2. # Module     : hstrings.hsm
  3. # Description: Functions related with strings.
  4. # Maintainer : Juergen Haible <juergen.haible@t-online.de>
  5. # Version    : 2000-05-07
  6. ########################################################################
  7. # NOTE:
  8. # This module is delivered with Hamster and it will be overwritten when
  9. # installing a new version of it. It might also be used by accompanying
  10. # demo-scripts, which depend on the current implementation.
  11. # So do NOT change this file unless you REALLY know what you do!
  12. ########################################################################
  13.  
  14. #!initialize
  15.    debug( 255, "<<< module 'hstrings.hsm' >>>" )
  16.    varset( $CRLF , chr(13) + chr(10) )
  17.    varset( $WSP  , chr(32) + chr( 9) )
  18. return( 0 )
  19.  
  20. ########################################################################
  21. # TrimWSP: Removes leading and trailing whitespace
  22. ########################################################################
  23. # [IN]  $string : line of text
  24. # [OUT] (result): $string with whitespace removed
  25. # Example: print( TrimWSP( $line ) )
  26.  
  27. sub TrimWSP( $string )
  28.    return( Trim( $string, $WSP ) )
  29. endsub
  30.  
  31. ########################################################################
  32. # PosWSP: Position of first whitespace-character within string
  33. ########################################################################
  34. # [IN]  $string : line of text
  35. # [OUT] (result): position of first whitespace-char; 0 if none
  36. # Example: print( PosWSP( $line ) )
  37.  
  38. sub PosWSP( $string )
  39.    var( $is, $it )
  40.    $is = Pos( " ", $string )
  41.    if( $is=0 )
  42.       return( Pos( chr(9), $string ) )
  43.    else
  44.       $it = Pos( chr(9), $string )
  45.       return( iif( ($it>0) && ($it<$is), $it, $is ) )
  46.    endif
  47. endsub
  48.